import LevelInitBase from "../LevelCommon/LevelInitBase";
import LevelControl1 from "../LevelControl/LevelControl1";
import RoundControl from "../LevelCommon/RoundControl";
import FocusParentObj from "../Prefabs/InteractivObj/Common/FocusParentObj";
import { utils } from "../../utils/CommonUtil";
import RotateObj from "../Prefabs/InteractivObj/Common/RotateObj";
import Sound from "../../constant/SoundNameConstant";
import GamePropObj from "../Prefabs/InteractivObj/Common/GamePropObj";
import CallToLevel from "../Prefabs/CallToLevel";
import Fire from "../Prefabs/InteractivObj/Fire";

export default class LevelInit1 extends LevelInitBase{

    private round1:Laya.Sprite3D;
    private container:Laya.Sprite3D;

    public startInitDetail(){
        this.levelRoot.addComponent(LevelControl1);
        this.round1 = this.LevelObjs.getChildByName("round1") as Laya.Sprite3D;

        this.round1.addComponent(RoundControl);
        this.container = this.round1.getChildByName("Container") as Laya.Sprite3D;

        //#region FocusParentObj
        let car = this.container.getChildByName("car") as Laya.Sprite3D;
        let FocusParentObj_car =utils.CommonUtils.CustomAddComponent(car,FocusParentObj) as FocusParentObj;
        FocusParentObj_car.cameraMoveTime = 1500;

        let FenceGate = this.container.getChildByName("FenceGate") as Laya.Sprite3D;
        let FocusParentObj_FenceGate =utils.CommonUtils.CustomAddComponent(FenceGate,FocusParentObj) as FocusParentObj;
        FocusParentObj_FenceGate.cameraMoveTime = 1000;

        let Rubbish = this.container.getChildByName("Rubbish") as Laya.Sprite3D;
        let FocusParentObj_Rubbish =utils.CommonUtils.CustomAddComponent(Rubbish,FocusParentObj) as FocusParentObj;
        FocusParentObj_Rubbish.cameraMoveTime = 1000;

        let poster_props = this.container.getChildByName("poster_props") as Laya.Sprite3D;
        let FocusParentObj_poster_props =utils.CommonUtils.CustomAddComponent(poster_props,FocusParentObj) as FocusParentObj;
        FocusParentObj_poster_props.cameraMoveTime = 1000;

        let Fire_focus = this.container.getChildByName("Fire_focus") as Laya.Sprite3D;
        let FocusParentObj_Fire_focus =utils.CommonUtils.CustomAddComponent(Fire_focus,FocusParentObj) as FocusParentObj;
        FocusParentObj_Fire_focus.cameraMoveTime = 1000;


        //#endregion


        //#region RotateObj
        let Trunk_props = car.getChildByName("Trunk_props") as Laya.Sprite3D;
        let RotateObj_Trunk_props =utils.CommonUtils.CustomAddComponent(Trunk_props,RotateObj) as RotateObj;
        RotateObj_Trunk_props.targetRotate = new Laya.Vector3(6,0,0);
        RotateObj_Trunk_props.rotateTime = 500;
        RotateObj_Trunk_props.isNeedCallToLevel = false;
        RotateObj_Trunk_props.IsRotateOnce = true;
        RotateObj_Trunk_props.VoiceName = Sound.soundClipArr.OPEN_GATE;

        let big_house = this.container.getChildByName("big house") as Laya.Sprite3D;
        let door_props = big_house.getChildByName("door_props") as Laya.Sprite3D;
        let RotateObj_door_props =utils.CommonUtils.CustomAddComponent(door_props,RotateObj) as RotateObj;
        RotateObj_door_props.targetRotate = new Laya.Vector3(0,45,0);
        RotateObj_door_props.rotateTime = 1000;
        RotateObj_door_props.isNeedCallToLevel = true;
        RotateObj_door_props.IsRotateOnce = false;

        let Fence_03_props = FenceGate.getChildByName("Fence_03_props") as Laya.Sprite3D;
        let RotateObj_Fence_03_props = utils.CommonUtils.CustomAddComponent(Fence_03_props,RotateObj) as RotateObj;
        RotateObj_Fence_03_props.targetRotate = new Laya.Vector3(0,-40,0);
        RotateObj_Fence_03_props.rotateTime = 500;
        RotateObj_Fence_03_props.isNeedCallToLevel = false;
        RotateObj_Fence_03_props.IsRotateOnce = true;
        //#endregion


        //#region GamePropObj
        let pliers_props=car.getChildByName("pliers_props") as Laya.Sprite3D;
        let GamePropObj_pliers_props =  utils.CommonUtils.CustomAddComponent(pliers_props,GamePropObj) as GamePropObj;
        GamePropObj_pliers_props.gamePropId = 4;

        let redBox = Rubbish.getChildByName("redBox") as Laya.Sprite3D;
        let GamePropObj_redBox = utils.CommonUtils.CustomAddComponent(redBox,GamePropObj) as GamePropObj;
        GamePropObj_redBox.gamePropId = 5;

        let Caustic_props = this.container.getChildByName("Caustic_props") as Laya.Sprite3D;
        let GamePropObj_Caustic_props = utils.CommonUtils.CustomAddComponent(Caustic_props,GamePropObj) as GamePropObj;
        GamePropObj_Caustic_props.gamePropId = 7;
        GamePropObj_Caustic_props.isNeedCallToLevel = true;

        let jinianpin =  this.Scene.getChildByName("jinianpin") as Laya.Sprite3D;
        let GamePropObj_jinianpin = utils.CommonUtils.CustomAddComponent(jinianpin,GamePropObj) as GamePropObj;
        GamePropObj_jinianpin.gamePropId = 11;

        let jinianpin1 =  this.Scene.getChildByName("jinianpin (1)") as Laya.Sprite3D;
        let GamePropObj_jinianpin1 = utils.CommonUtils.CustomAddComponent(jinianpin1,GamePropObj) as GamePropObj;
        GamePropObj_jinianpin1.gamePropId = 11;

        let jinianpin2 =  this.Scene.getChildByName("jinianpin (2)") as Laya.Sprite3D;
        let GamePropObj_jinianpin2 = utils.CommonUtils.CustomAddComponent(jinianpin2,GamePropObj) as GamePropObj;
        GamePropObj_jinianpin2.gamePropId = 11;

        //#endregion


        //#region CallToLevel
        let Fences =  this.container.getChildByName("Fences") as Laya.Sprite3D;
        let CallToLevel_Fire_focus =utils.CommonUtils.CustomAddComponent(Fences,CallToLevel) as CallToLevel;

        let Iron_chain_props =  FenceGate.getChildByName("Iron chain_props") as Laya.Sprite3D;
        let CallToLevel_Iron_chain_props =utils.CommonUtils.CustomAddComponent(Iron_chain_props,CallToLevel) as CallToLevel;
        //#endregion

        //#region Fire
        let fire = Fire_focus.getChildByName("fire") as Laya.Sprite3D;
        let Fire_fire = utils.CommonUtils.CustomAddComponent(fire,Fire) as Fire;
        Fire_fire.fireNeedObjId = 6;
        Fire_fire.canFireObjId = 7;
        fire.getChildByName("fireEff").active = false;
        //#endregion

    }
}